﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SecurityDev
{
    public partial class AlertDetail : Form
    {
        string alertPhotoUrl;
        decimal obj_seq;

        public AlertDetail(decimal alert_seq)
        {
            InitializeComponent();

            var alertR = DS.outpost.alert.FindByalert_seq(Convert.ToDecimal(alert_seq));

            alertPhotoUrl = alertR.alert_photo_url;
            obj_seq = alertR.dvrRow.obj_seq;
            
            dvr_ip.Text = alertR.dvrRow.dvr_ip;
            dvr_name.Text = alertR.dvrRow.dvr_name;
            alert_date.Text = alertR.alert_date.ToString();
            alert_time.Text = alertR.alert_time.ToString();
            alert_state.Text = alertR.alert_state.ToString();
        }

        private void AlertDetail_Load(object sender, EventArgs e)
        {
            LoadImage(alert_photo, alertPhotoUrl, false);
        }
         
        /// <summary>
        /// Load Image method
        /// </summary>
        /// <param name="path"></param>
        private void LoadImage(PictureBox p1, string path, bool type)
        {
            // if (type == true) - open in Browser - else only on Form
            if (type == true)
            {
                ProcessStartInfo sInfo = new ProcessStartInfo(path);
                Process.Start(sInfo);
            }
            try
            {
                p1.Load(path);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void objectDetailBtn_Click(object sender, EventArgs e)
        {
            (new ObjectDetail(obj_seq)).ShowDialog();
        }

    }
}
